//
//  YBNoticeBackListViewController.m
//  GongXinDangJian
//
//  Created by apple on 17/12/21.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "YBNoticeBackListViewController.h"
#import "YBNoticeBackListTableViewCell.h"
#define CELLID @"YBNoticeBackListTableViewCell"

@interface YBNoticeBackListViewController ()<UITableViewDelegate , UITableViewDataSource>

@property (nonatomic , strong) UITableView * tableView;

@end

@implementation YBNoticeBackListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.titlelabel.text = @"撤回通知";
    [self.view addSubview:self.tableView];
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataArray.count;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return ItemHeight * 130;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    YBNoticeBackListTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CELLID forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.model = self.dataArray[indexPath.row];
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    YBAcceptMessageListModel * model = self.dataArray[indexPath.row];
    YBNoticeBackListTableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];
    [YBRequestManager request_readNoticeBackWithMsgId:model.ID successBlock:^(id object) {
        NetWorkModel *netModel = [NetWorkModel yy_modelWithJSON:object];
        if ([netModel.STATE integerValue] == 20000) {
            [cell resetLabelTextColor];
        }
    } failBlock:^(id object) {
        
    }];
    YBMessageDetailView * detailView = [[YBMessageDetailView alloc]initNormalMessageNoRequestDetailViewWithMessageModel:model];
    detailView.frame = CGRectMake([UIScreen zj_screenWith], 0, [UIScreen zj_screenWith], [UIScreen zj_screenHeight]);
    [[UIApplication sharedApplication].keyWindow addSubview:detailView];
    [UIView animateWithDuration:0.2f animations:^{
        detailView.frame = CGRectMake(0, 0, [UIScreen zj_screenWith], [UIScreen zj_screenHeight]);
    } completion:^(BOOL finished) {
        
    }];
}


- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return nil;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.000000001;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.000000001;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return nil;
}


-(UITableView *)tableView
{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, navHeight, [UIScreen zj_screenWith], [UIScreen zj_screenHeight] - navHeight) style:UITableViewStyleGrouped];
        [_tableView registerClass:[YBNoticeBackListTableViewCell class] forCellReuseIdentifier:CELLID];
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.backgroundColor = [UIColor themeGrayColor];
        [_tableView adaptiveIOS11];
        
    }
    return _tableView;
}


@end
